package com.zhuangxiaoyan.springboot.mybatis.Repository;

import com.zhuangxiaoyan.springboot.mybatis.dao.ProductMapper;
import com.zhuangxiaoyan.springboot.mybatis.domain.Product;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @author xjl
* @description ProductDAO类
* @createDate 2025-01-11 18:22:55
* @Entity mybatis.domain.Product
*/
@Repository
public class ProductRepository {

    @Autowired
    private ProductMapper productMapper;

    public int addProduct(Product product) {
        return productMapper.insertProduct(product);
    }

    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    public int removeProduct(long id) {
        return productMapper.removeProduct(id);
    }

    public Product getProductById(long id) {
        return productMapper.getProductById(id);
    }

    public List<Product> getAllProducts() {
        return productMapper.getAllProducts();
    }
}




